package com.sdleyou.treepro.common.rabbitmq.receiver;

import com.sdleyou.treepro.common.constant.Constants;
import com.sdleyou.treepro.common.model.dao.UserPetDO;
import com.sdleyou.treepro.common.service.UserPetManager;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Component
@EnableRabbit
@Configuration
public class ImmediateReceiver {

    @Autowired
    private UserPetManager userPetManager;

    @RabbitListener(queues = Constants.IMMEDIATE_QUEUE)
    @RabbitHandler
    public void get(UserPetDO userPetDO) {
        userPetManager.finishHunt(userPetDO);
    }
}